//
//  DnpEquipment.m
//  dnp_plugin
//
//

#import "DnpEquipment.h"
#import "DnpEquipmentKeychain.h"
#import <sys/utsname.h>
#import <AdSupport/AdSupport.h>

@implementation DnpEquipment

+ (NSString *)fearlessness {
    NSString *idfa = [[NSUserDefaults standardUserDefaults] stringForKey:@"KDnpIDFA"];
        
    if (idfa.length > 0) {
        return idfa;
    }
    
    return @"";
}

+ (NSString *)footed {
    
    NSString *handled = [[DnpEquipmentKeychain sharedInstance] getData];
    
    if (handled.length > 0) {
        return handled;
    }
    
    NSString *result = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
    [[DnpEquipmentKeychain sharedInstance] saveData:result];
    return result;
}

+ (NSString *)holiday {
    NSString *key = @"CFBundleShortVersionString";
    NSString *holiday = [[NSBundle mainBundle] objectForInfoDictionaryKey:key];
    
    if (holiday) {
        return holiday;
    }
    return @"1.0.0";
}

+ (NSString *)considerably {
    return [[UIDevice currentDevice] systemVersion];
}

+ (NSString *)sysName {
    return [[UIDevice currentDevice] systemName];
}

+ (NSString *)cannot {
    struct utsname systemInfo;
    uname(&systemInfo);
    
    NSString *deviceModel = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];
    
    return deviceModel;
}

+ (NSString *)afford {
    return [[UIDevice currentDevice] model];
}

+ (NSString *)largest {
    NSInteger t = [NSTimeZone localTimeZone].secondsFromGMT / 3600;
    if (t <= 0) {
        return [NSString stringWithFormat:@"GMT%ld", (long)t];
    } else {
        return [NSString stringWithFormat:@"GMT+%ld", (long)t];
    }
}

+ (NSString *)autou {
    NSArray *languages = [NSLocale preferredLanguages];
        
    if (languages.count > 0) {
        return languages.firstObject ?: @"en";
    }
    
    return @"en";
}

+ (NSString *)ten {
    BOOL tenFlag = TARGET_IPHONE_SIMULATOR == 1 && TARGET_OS_IPHONE == 1;
    return tenFlag ? @"1" : @"0";
}

+ (NSString *)should {
    BOOL shouldFlag = [[NSFileManager defaultManager] fileExistsAtPath:@"/User/Applications/"];
    return shouldFlag ? @"1" : @"0";
}

@end
